package com.eastfair.es.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@Document(indexName = "product_#{ T(com.eastfair.core.context.ContextUtil).getEsIndexSuffix() }", type = "_doc")//指定映射es中的索引
@Mapping(mappingPath = "productIndex.json") // 解决IK分词不能使用问题
public class Student implements Serializable {
    @Id
    @Field(index = true, store = true, type = FieldType.Keyword)
    private String id;

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String sName;

    @Field(index = true, store = true, type = FieldType.Text, analyzer = "ik_smart")
    //Text可以分词 ik_smart=粗粒度分词 ik_max_word 为细粒度分词
    private String sAddress;

    @Field(index = false, store = true, type = FieldType.Integer)
    private Integer sAge;

//    @Field(index = false, store = true, type = FieldType.Date, format = DateFormat.basic_date_time)
    @Field(index = false, store = true, type = FieldType.Date, format = DateFormat.date_time,pattern = "yyyy-MM-ddTHH:mm:ss.SSSZ")
//    @Field(type = FieldType.Date, format = DateFormat.custom,
//            pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||yyyy-MM-dd'T'HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date sCreateTime;

//    @Field(index = false, store = true, type = FieldType.Object)
//    private Headmaster sHeadmaster;//班主任

    @Field(index = true, store = false, type = FieldType.Keyword)
    private String[] sCourseList; //数组类型 由数组中第一个非空值决定(这里数组和集合一个意思了)

    @Field(index = true, store = false, type = FieldType.Keyword)
    private List<String> sColorList; //集合类型 由数组中第一个非空值决定

}
